#include        <stdio.h>
#include        <stdlib.h>
#include        <netinet/in.h>
#include        <sys/socket.h>

//#include 	<cstring>
#include 	<errno.h>
#include 	<string.h> //bzero
#include 	<sys/types.h>  //AF_INET
#include 	<arpa/inet.h>  //inet_ntoa
#include 	<unistd.h>  //close


#define MAXLINE         256
#define SA              struct sockaddr
#define Port_Serv       2335

int cont = 1;

int inicio (char * msg) {
	
    char  *texto = msg;
	//while(1 < 2)	{	
	
		
        int     sockfd, n; //sockfd - socket criado
	    //char recvline[MAXLINE + 1];
        struct sockaddr_in servaddr;

        if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0){   // criação do socket 
                printf("Erro no socket\n");
                exit(1);
        }
		
        bzero(&servaddr, sizeof(servaddr));
        
         
        servaddr.sin_family = AF_INET;
        servaddr.sin_port   = htons(2335);
        servaddr.sin_addr.s_addr = inet_addr("172.16.0.49");
        		    
		if (connect(sockfd, (SA *) &servaddr, sizeof(servaddr)) < 0){
                printf("Erro de conexão");
                exit(4);
        }
		
		
		printf("msg: %d - ",cont);
		printf("Mensagem armazenada: %s\n " , texto); 	
		//printf("TESTE %d", cont);	
		cont = cont+1;
		//printf("TESTE %d", cont);
		send(sockfd, texto, 256, 0);
	
	//}
	
	//exit(0);
}
